package de.fzi.kasma.learner.gui;

import java.awt.Dimension;
import java.awt.Toolkit;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;

public class StartGui {
	
	public ILPSettingsTab  ilpTab;
	public EPTab epTab;
	public RunTab runTab;
	public final TabFolder tabFolder;
	public Display display;
	public Shell shell;
	  
  public StartGui() {

		display = new Display();
		shell = new Shell(display);
	   //center frame

		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		screenSize.height = screenSize.height/2;
		screenSize.width = screenSize.width/2;
		int height = 580/2;
		int width = 800/2;
		int y = screenSize.height - height;
		int x = screenSize.width - width;
	   shell.setBounds(x, y, 800, 580);
	   FillLayout flayout = new FillLayout(SWT.VERTICAL);
	   shell.setLayout(flayout);
       shell.setText("RDF Learner");
       
       Image icon = new Image(display, "data/zero.gif");
       shell.setImage(icon);



       tabFolder = new TabFolder (shell, SWT.NONE);


    //First tab (the welcome picture)
   
    TabItem welcomeTab = new TabItem (tabFolder, SWT.NONE);
    welcomeTab.setText ("Welcome");
    Composite cmp = new Composite(tabFolder, SWT.BORDER);  
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    data.horizontalAlignment = SWT.CENTER;
    cmp.setLayoutData(data);
    welcomeTab.setControl(cmp);
    GridLayout layout = new GridLayout();
    cmp.setLayout(layout);
    Label label = new Label(cmp, SWT.CENTER);
    label.setLayoutData(data);
    Image image = new Image(display, "data/demo3.gif");
    label.setImage(image);
    
    Label label2 = new Label(cmp, SWT.END);
    label2.setAlignment(SWT.RIGHT);
    Image image2 = new Image(display, "data/info.gif");
    label2.setImage(image2);  

    //Second tab, configuration of the parameters
    ilpTab = new ILPSettingsTab(this, tabFolder, SWT.NORMAL);

	//new Parameter Tab (EP parameters)
	
    epTab = new EPTab(this, tabFolder, SWT.NORMAL);
    
   //Forth tab, run the algorithm 
        
    runTab = new RunTab(this, tabFolder, SWT.NORMAL);
       
    
    shell.open();
    
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
      display.sleep();
      }
    }
    display.dispose();
  }
 

public static void main(String[] args) {
    new StartGui();
  }


}
